package com.bum.api.processor.rss.html;

import org.apache.commons.lang.StringUtils;

import com.bum.api.core.exp.om.Metas;
import com.bum.api.core.exp.om.Params;
import com.bum.api.core.service.process.ApiProcess;
import com.bum.api.processor.rss.html.bo.RssAppHtmlViewBO;
import com.bum.api.processor.rss.html.bo.RssHtmlViewBO;

public class RssHtmlProcess extends ApiProcess {
	RssHtmlViewBO		rssHtmlViewBO;
	RssAppHtmlViewBO	rssAppHtmlViewBO;

	@Override
	public String process(String path, Params params, Metas metas) {
		if (path.startsWith("rss/view/")) {
			path = path.substring(9);
		}
		path = path.replace(".html", "");

		if ("rss/sitemap".equals(path)) {
			return rssHtmlViewBO.sitemap(path, params, metas);
		}

		String[] parts = StringUtils.split(path, "/", 2);

		if (parts.length > 1) {
			return rssHtmlViewBO.view(parts[1], params, metas);
		}

		return rssHtmlViewBO.sites(null, params, metas);
	}

	public void setRssHtmlViewBO(RssHtmlViewBO rssHtmlViewBO) {
		this.rssHtmlViewBO = rssHtmlViewBO;
	}

	public void setRssAppHtmlViewBO(RssAppHtmlViewBO rssAppHtmlViewBO) {
		this.rssAppHtmlViewBO = rssAppHtmlViewBO;
	}

}
